import java.io.File;
import java.io.IOException;
import java.util.List;
import java.lang.Number;
 
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood;
import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
import org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender;
import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender;
import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
import org.apache.mahout.cf.taste.impl.similarity.LogLikelihoodSimilarity;
import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
import org.apache.mahout.cf.taste.recommender.RecommendedItem;
import org.apache.mahout.cf.taste.recommender.Recommender;
import org.apache.mahout.cf.taste.similarity.ItemSimilarity;
import org.apache.mahout.cf.taste.similarity.UserSimilarity;
 
public class ItemBasedRecommender {
	public static void main(String[] args) throws TasteException, IOException {
		DataModel model;
		model = new FileDataModel(new File(args[0]));

		ItemSimilarity similarity = new LogLikelihoodSimilarity(model);
		
		Recommender recommender =
	          new GenericItemBasedRecommender(model, similarity);
		Recommender cachingRecommender = new CachingRecommender(recommender);
		
		List<RecommendedItem> recommendations = cachingRecommender.recommend(Long.valueOf(args[1]), 30);
		for (RecommendedItem recommendedItem : recommendations) {
			System.out.println(recommendedItem);
		}
 
	}
} 
